package org.arch_learn.dubbo_demo.dubbo_spi_demo;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.arch_learn.dubbo_demo.dubbo_spi_demo_api.service.HelloService;

public class DubboSpiAdaptiveMain {
    public static void main(String[] args) {
        URL url = URL.valueOf("test://localhost:8080/hello?hello.service=dog");
        HelloService adaptiveExtension = ExtensionLoader.getExtensionLoader(HelloService.class).getAdaptiveExtension();
        String s = adaptiveExtension.sayHello(url);
        System.out.println(s);

        //未指定的话，会使用@SPI注解括号里面的默认值作为key取得相应实现
        url = URL.valueOf("test://localhost:8080/hello");
        adaptiveExtension = ExtensionLoader.getExtensionLoader(HelloService.class).getAdaptiveExtension();
        s = adaptiveExtension.sayHello(url);
        System.out.println(s);
    }
}
